using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Carmall.Entity;
using Carmall.IDAL;

namespace Carmall.DAL
{
	/// <summary>
	/// Sellorder 的摘要说明。
	/// </summary>
	public class Sellorder : BaseDAL<SellorderInfo>, ISellorder
	{
		#region 对象实例及构造函数

		public static Sellorder Instance
		{
			get
			{
				return new Sellorder();
			}
		}
		public Sellorder() : base("sellorder","OrderID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override SellorderInfo DataReaderToEntity(IDataReader dataReader)
		{
			SellorderInfo sellorderInfo = new SellorderInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			sellorderInfo.OrderID = reader.GetInt64("OrderID");
			sellorderInfo.UserID = reader.GetInt64("UserID");
			sellorderInfo.RequireTime = reader.GetDateTime("RequireTime");
			sellorderInfo.Created = reader.GetDateTime("Created");
			sellorderInfo.Contact = reader.GetString("Contact");
			sellorderInfo.Tel = reader.GetString("Tel");
			sellorderInfo.Notes = reader.GetString("Notes");
			sellorderInfo.Status = reader.GetInt32("Status");
			
			return sellorderInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(SellorderInfo obj)
		{
		    SellorderInfo info = obj as SellorderInfo;
			Hashtable hash = new Hashtable(); 
			
			hash.Add("OrderID", info.OrderID);
 			hash.Add("UserID", info.UserID);
 			hash.Add("RequireTime", info.RequireTime);
 			hash.Add("Created", info.Created);
 			hash.Add("Contact", info.Contact);
 			hash.Add("Tel", info.Tel);
 			hash.Add("Notes", info.Notes);
 			hash.Add("Status", info.Status);
 				
			return hash;
		}

    }
}